import Common from '../../common/common.js';

function BaseListItem(data) {
    this.element;
    this.data = data;
    this.initElement();
    this.name = "";
 }

BaseListItem.prototype = {
    initElement: function () {
        this.element = Common.tool.createElement({
            label: "li",
            childNodes: [
                {
                    label: "div",
                    tag:"avatarDiv",
                    props: {className: "avatarDiv"},
                    childNodes: [
                        {
                            label: "img",
                            tag:"avatarImg",
                            props: {className: "avatarImg"}
                        }
                    ]
                },
                {
                    label: "div",
                    tag:"infoDiv",
                    props: {className: "infoDiv"},
                    childNodes: [
                        {
                            label: "div",
                            tag:"infoName",
                            props: {className: "infoName"}
                        },
                        {
                            label: "div",
                            tag:"infoNsg",
                            props: {className: "infoNsg"}
                        }
                    ]
                },
                {
                    label: "div",
                    tag:"otherDiv",
                    props: {className: "otherDiv"},
                    childNodes: [
                        {
                            label: "div",
                            tag:"otherInfo",
                            props: {className: "otherInfo"}
                        }
                    ]
                },
                {
                    label: "div",
                    tag:"handle",
                    props: {className: "handle"},
                    childNodes:  this.initHandleData()
                }
            ]
        });
        this.bind();
    },
    initHandleData:function(){
        return [];
    },
    //设置头像
    setAvatar:function(avatar){
        this.element.avatarDiv.avatarImg.src = Common.tool.getAvatar(avatar)
    },
    //设置名称
    setName:function (name) {
        this.element.infoDiv.infoName.innerText = name;
        this.name = name;
    },
    //设置副消息
    setMsg:function (value) {
        this.element.infoDiv.infoNsg.innerText = value;
    },
    //设置其它信息
    setOther:function(other){
        this.element.otherDiv.otherInfo.innerText = other;
    },
    remove:function(){
        this.element.parentElement.removeChild(this.element);
    },
    bind:function(){}
}

export default BaseListItem;
